package com.zxy.ider.ehome.widget;

import android.view.View;
import android.view.ViewGroup;

/**
 * 
* @ClassName: WidgetTvViewBring 
* @Description:璁￢iewGroup涓殑鎺т欢鍦ㄦ渶涓婂眰
* @author zhaoyufei
* @date 2016-7-1 涓嬪崍5:00:07
 */

public class WidgetTvViewBring {

	private int position = 0;

	public WidgetTvViewBring() {
	}

	public WidgetTvViewBring(ViewGroup vg) {
		vg.setClipChildren(false);
		vg.setClipToPadding(false);
		// vg.setChildrenDrawingOrderEnabled(true);
	}

	public void bringChildToFront(ViewGroup vg, View child) {
		position = vg.indexOfChild(child);
		if (position != -1) {
			vg.postInvalidate();
		}
	}

	/**
	 * 姝ゅ嚱锟�?? dispatchDraw 涓皟锟�??. <br>
	 * 鍘熺悊灏辨槸鍜屾渶鍚庝竴涓缁樺埗鐨剉iew锛屼氦鎹簡浣嶇疆. <br>
	 * 鍥犱负dispatchDraw锟�??鍚庝竴涓粯鍒剁殑view鏄湪锟�??涓婂眰锟�??. <br>
	 * 杩欐牱灏遍伩鍏嶄簡浣跨敤 bringToFront 瀵艰嚧鐒︾偣閿欎贡闂. <br>
	 */
	public int getChildDrawingOrder(int childCount, int i) {
		if (position != -1) {
			if (i == childCount - 1)
				return position;
			if (i == position)
				return childCount - 1;
		}
		return i;
	}

}
